package it.abc.sicsic.view.backing.clienti;

import it.abc.sicsic.JavaServiceFacade;
import it.abc.sicsic.view.util.ViewUtil;
import it.abc.sicsic.model.clienti.Clienti;
import java.util.List;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.event.ActionEvent;


import oracle.adf.view.rich.component.rich.data.RichTable;
import oracle.adf.view.rich.component.rich.input.RichInputText;
import oracle.adf.view.rich.component.rich.nav.RichCommandButton;

//import org.apache.log4j.Logger;
import org.apache.myfaces.trinidad.event.SelectionEvent;

@ManagedBean(name = "backing_gestioneClienti")
@SessionScoped


public class GestioneClienti {

    private RichInputText itNome;
    private RichInputText itCognome;
    private RichInputText itRagSociale;
    private RichInputText itCitta;
    private RichInputText itDocumento;
    private RichInputText itTelefono;
    private RichTable tableClienti;
    private RichCommandButton cerca;
   // private static Logger logger = Logger.getLogger(GestioneClienti.class); 

    public GestioneClienti(){
     //       logger.info("GestioneClienti start");
     //       logger.info("fromPage=" + ViewUtil.getRequestFromPage());  
        }
    public void setItNome(RichInputText it1) {
        this.itNome = it1;
    }

    public RichInputText getItNome() {
        return itNome;
    }


    public void setItCognome(RichInputText it2) {
        this.itCognome = it2;
    }

    public RichInputText getItCognome() {
        return itCognome;
    }

    public void setItRagSociale(RichInputText it3) {
        this.itRagSociale = it3;
    }

    public RichInputText getItRagSociale() {
        return itRagSociale;
    }

    public void setItCitta(RichInputText it4) {
        this.itCitta = it4;
    }

    public RichInputText getItCitta() {
        return itCitta;
    }

    public void setItDocumento(RichInputText it5) {
        this.itDocumento = it5;
    }

    public RichInputText getItDocumento() {
        return itDocumento;
    }

    public void setItTelefono(RichInputText it6) {
        this.itTelefono = it6;
    }

    public RichInputText getItTelefono() {
        return itTelefono;
    }

    public void setTableClienti(RichTable t1) {
        this.tableClienti = t1;
    }

    public RichTable getTableClienti() {
        return tableClienti;
    }

    public void setCerca(RichCommandButton cerca) {
        this.cerca = cerca;
    }

    public RichCommandButton getCerca() {
        return cerca;
    }

    public void cerca(ActionEvent actionEvent) {
        JavaServiceFacade serviceFacade =new JavaServiceFacade();
        List<Clienti> list = null;
        list = serviceFacade.getClienti(getNome(), getCognome(), getRagioneSociale(), getCitta(),getDocumento(), getTelefono());
        tableClienti.setValue(list);
    }
    
    private String getNome(){
        return ViewUtil.getStringValue(getItNome());    
    }
    private String getCognome(){
        return ViewUtil.getStringValue(getItCognome());
    }
    private String getRagioneSociale(){
        return ViewUtil.getStringValue(getItRagSociale());
    }
    private String getCitta(){
        return ViewUtil.getStringValue(getItCitta());
    }
    private String getDocumento(){
        return ViewUtil.getStringValue(getItDocumento());
    }
    private String getTelefono(){
        return ViewUtil.getStringValue(getItTelefono());
    }

    public void tableSelection(SelectionEvent selectionEvent) {
   //    logger.info("click");
    }
}